if (NOT TARGET "test-drive::test-drive")
  find_package("test-drive" REQUIRED)
endif()

if(WIN32)
  if(CMAKE_Fortran_COMPILER_ID MATCHES "^Intel")
    add_link_options(/Qoption,link,/STACK:8388608)
  elseif(CMAKE_Fortran_COMPILER_ID STREQUAL GNU)
    add_link_options(-Wl,--stack,8388608)
  endif()
endif()

macro(ADDTEST name)
    add_executable(test_${name} test_${name}.f90)
    target_link_libraries(test_${name} "${PROJECT_NAME}" "test-drive::test-drive")
    add_test(NAME ${name}
             COMMAND $<TARGET_FILE:test_${name}> ${CMAKE_CURRENT_BINARY_DIR}
             WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
endmacro(ADDTEST)

macro(ADDTESTPP name)
    add_executable(test_${name} test_${name}.F90)
    target_link_libraries(test_${name} "${PROJECT_NAME}" "test-drive::test-drive")
    add_test(NAME ${name}
             COMMAND $<TARGET_FILE:test_${name}> ${CMAKE_CURRENT_BINARY_DIR}
             WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
endmacro(ADDTESTPP)


add_subdirectory(array)
add_subdirectory(ascii)
if (NOT STDLIB_NO_BITSET)
  add_subdirectory(bitsets)
endif()
add_subdirectory(constants)
add_subdirectory(hash_functions)
add_subdirectory(hash_functions_perf)
add_subdirectory(hashmaps)
add_subdirectory(intrinsics)
add_subdirectory(io)
add_subdirectory(linalg)
add_subdirectory(logger)
add_subdirectory(optval)
add_subdirectory(selection)
add_subdirectory(sorting)
add_subdirectory(specialfunctions)
add_subdirectory(stats)
add_subdirectory(string)
add_subdirectory(system)
add_subdirectory(quadrature)
add_subdirectory(math)
add_subdirectory(stringlist)
add_subdirectory(terminal)
